package com.tang.model.composite.safe;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author tangyuan2meicloud.com
 * @DATE 2021/8/22 20:55
 * @Desc
 * @Remarks
 */
public class Folder extends Dirictory {
    List<Dirictory> dirs;
    public Integer level;

    public Folder(String name, Integer level) {
        this.name = name;
        this.dirs = new ArrayList<Dirictory>();
        this.level = level;
    }

    public void list() {
        for (Dirictory dir : dirs) {
            System.out.println(dir.name);
        }
    }

    public void addDirictory(Dirictory dirictory) {
        dirs.add(dirictory);
    }

    public void removeDirictory(Dirictory dirictory) {
        dirs.remove(dirictory);
    }

    public void show() {
        System.out.println(name);
        for (Dirictory dir : dirs) {
            if (this.level != null) {
                for (int i = 0; i < level; i++) {
                    System.out.print("  ");
                }

                for (int i = 0; i < level; i++) {
                    if (i == 0) {
                        System.out.print("+");
                    }
                    System.out.print("--");
                }
            }
            dir.show();
        }
    }
}
